import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "normalize.css";
import "@/assets/css/common.scss";
import SkeletonView from "./components/utils/SkeletonView.vue";
Vue.component("SkeletonView", SkeletonView);
Vue.config.productionTip = false;
import errorimg from "./assets/下载.png";
Vue.directive("lazy", {
  inserted(el, binding) {
    const observer = new IntersectionObserver(([{ isIntersecting }]) => {
      if (isIntersecting) {
        observer.unobserve(el);
        el.src = binding.value;
        // 图片加载失败
        el.onerror = () => {
          el.src = errorimg;
        };
      }
    });
    observer.observe(el);
  },
});

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
